//
//  YWNarViewController.m
//  YWBaseFrameWork
//
//  Created by NeiQuan on 16/6/8.
//  Copyright © 2016年 NeiQuan. All rights reserved.
//

#import "YWNarViewController.h"
#import "YWheader.h"
#import "UIBarButtonItem+Extension.h"
@interface YWNarViewController ()<UIGestureRecognizerDelegate>

@end

@implementation YWNarViewController
// 当类第一次被加载的时调用
+ (void)initialize{
    //设置导航条的样式
    UINavigationBar *navBar = [UINavigationBar appearance];
    [navBar setBarTintColor:[UIColor whiteColor]];
    [navBar setTintColor:[UIColor whiteColor]];
    [navBar setBackgroundColor:[UIColor whiteColor]];
   // navBar.translucent = YES;
    ////设置标题的颜色
    [navBar  setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor  colorWithString:@"#F4AE25"],NSFontAttributeName:[UIFont systemFontOfSize:24]}];
    
    // 取出导航条item的外观对象(主题对象)
    UIBarButtonItem *item = [UIBarButtonItem appearance];
    //设置默认状态文字的颜色
    NSMutableDictionary *md = [NSMutableDictionary dictionary];
    md[NSForegroundColorAttributeName] = [UIColor blackColor];
    [item setTitleTextAttributes:md forState:UIControlStateNormal];
    
    // 设置高亮状态文字的颜色
    NSMutableDictionary *higMd = [NSMutableDictionary dictionary];
    higMd[NSForegroundColorAttributeName] = [UIColor whiteColor];
    [item setTitleTextAttributes:higMd forState:UIControlStateHighlighted];
    
    // 设置不可用状态的颜色
    NSMutableDictionary *disMd = [NSMutableDictionary dictionary];
    disMd[NSForegroundColorAttributeName] = [UIColor grayColor];
    [item setTitleTextAttributes:disMd forState:UIControlStateDisabled];
    
}

//- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
//{
//    // 注意：只有非根控制器才有滑动返回功能，根控制器没有。
//    // 判断导航控制器是否只有一个子控制器，如果只有一个子控制器，肯定是根控制器
//    if (self.childViewControllers.count == 1) {
//        // 表示用户在根控制器界面，就不需要触发滑动手势，
//        return NO;
//    }
//    return YES;
//    
//}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.interactivePopGestureRecognizer.delegate = self;
}
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0)
    {
        viewController.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithImage:@"设置_03" higImage:@"设置_03" target:self action:@selector(pop)];
        viewController.hidesBottomBarWhenPushed = YES;
    }
    
    [super pushViewController:viewController animated:animated];
    
}
#pragma mark 返回上一层
- (void)pop{
    [self popViewControllerAnimated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

@end
